package com.rest.core.filter;

import java.io.IOException;

import javax.annotation.Priority;
import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.ext.Provider;

import org.apache.commons.lang.StringUtils;

import com.rest.core.auth.Auth;
import com.rest.core.exception.BaseException;

/**
 * 权限验证过滤器
 * @Description:实现服务端请求过滤
 * @Package com.rest.core.filter.AuthRequestFilter
 * @author Smile- 2016年4月13日 下午10:40:33
 */
@Auth
@Provider  
@Priority(Priorities.AUTHENTICATION)
public class AuthRequestFilter implements ContainerRequestFilter {

	@Override
	public void filter(ContainerRequestContext requestContext)
			throws IOException {
		String headerString = requestContext.getHeaderString("toke");
		if (StringUtils.isEmpty(headerString)) {
			throw new BaseException("你谁啊你？");
		}
		System.out.println("权限控制");
	}

}
